<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">
<body>
	<ui:composition>
		<p:accordionPanel multiple="true" id="poAccordion"  style="background-color:#F5FFF5;"
			activeIndex="#{dtPurchaseOrderRequestView.activeIndex}"
			value="#{dtPurchaseOrderRequestView.purchaseOrders}"
			var="purchaseOrder">
			<p:tab  style="background-color:#F5FFF5;"
				title="#{purchaseOrder.supplier.name} : #{purchaseOrder.status}">
				<h:form  style="background-color:#F5FFF5;">
					<p:panelGrid>
						<f:facet name="header">
							<p:row>
								<p:column>
									<h:outputText value="PO#" />
								</p:column>
								<p:column>
									<h:outputText value="Target Warehouse" />
								</p:column>
								<p:column>
									<h:outputText value="Currency" />
								</p:column>
								<p:column>
									<h:outputText value="Terms" />
								</p:column>
								<p:column>
									<h:outputText value="Total" />
								</p:column>
								<p:column>
									<h:outputText value="Status" />
								</p:column>
							</p:row>
						</f:facet>
						<p:row>
							<p:column>
								<h:outputText value="#{purchaseOrder.id}" />
							</p:column>
							<p:column>
								<h:outputText value="#{purchaseOrder.warehouse.name}" />
							</p:column>
							<p:column>
								<h:outputText value="PHP" />
							</p:column>
							<p:column>
								<h:outputText value="#{purchaseOrder.terms}" />
							</p:column>
							<p:column>
								<h:outputText value="#{purchaseOrder.total}" />
							</p:column>
							<p:column>
								<h:outputText value="#{purchaseOrder.status}" />
							</p:column>
						</p:row>
					</p:panelGrid>
					<br />
					<ui:include
						src="/WEB-INF/templates/entity/purchaseOrder.items.xhtml">
						<ui:param name="bean" value="#{purchaseOrder}" />
						<ui:param name="deleteUpdate" value=":poReqForm :poAccordion" />
						<ui:param name="backingBean" value="#{dtPurchaseOrderRequestView}" />
						<ui:param name="readonly" value="#{purchaseOrder.status != 'OPEN'}" />
					</ui:include>
					<br />
					<h3>Adjustments</h3>

					<p:dataTable var="adjustment" value="#{purchaseOrder.adjustments}">
						<p:column headerText="Description">
							<h:outputText value="#{adjustment.description}" />
						</p:column>
						<p:column headerText="Sub-Total">
							<h:outputText value="#{adjustment.amount}" />
						</p:column>
					</p:dataTable>

					<br />
					<p:commandButton value="Discard" ajax="false"
						rendered="#{empty purchaseOrder.items}" 
						action="#{dtPurchaseOrderRequestView.deletePurchaseOrder}">
						<f:param name="poId" value="#{purchaseOrder.id}" />
					</p:commandButton>
					<p:commandButton value="Open" ajax="false"
						rendered="#{not empty purchaseOrder.items}"
						action="#{dtPurchaseOrderEditView.openPurchaseOrder}">
						<f:param name="poId" value="#{purchaseOrder.id}" />
					</p:commandButton>
				</h:form>

			</p:tab>
		</p:accordionPanel>
	</ui:composition>
</body>
</html>